<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Health extends CF_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->load->model('health_mdl');
		$this->load->model('xiangke_mdl');
		$this->load->library('category');
		$this->uid = $this->user_login->is_logged_in() ? $this->user_login->get_user_id() : 0;
	}

	public function index()
	{
		$this->lists();
	}
	/**
	 * 菜谱内容页
	 * @param  string $id [description]
	 * @return [type]     [description]
	 */
	public function views($id='')
	{
		$this->load->helper('text');
		
		/** 如为空，则跳转 */
		if (empty($id) || !is_numeric($id)) redirect(site_url());
		//获取菜谱信息
		$data['health_info'] = $health_info = $this->health_mdl->get_by(array('id'=>$id));

		/** 不存在? */
		if (!$data['health_info']) show_404();

		$this->health_mdl->update_views($id);	//更新菜谱浏览次数
		//获取发布此菜的用户
		$data['youyi_group'] = $this->health_mdl->get_health_by_shicai_id($health_info['youyi_group'])->result_array();
		$data['jinji_group'] = $this->health_mdl->get_health_by_shicai_id($health_info['jinji_group'])->result_array();
		$data['shicai_xiangke'] = $this->xiangke_mdl->get(NULL, 0, 10)->result_array();

		$this->load->view('health_views',$data);
	}

	public function lists()
	{
		/* 分页配置 */
		$data['shicai_xiangke'] = $this->xiangke_mdl->get(NULL, 0, 10)->result_array();
		$data['cate'] = $this->category->getAllCategory(0, false, 1, false, 3);

		//$data['cate_info'] = $this->category->fetchOne($cid);
		$this->load->view('health',$data);
	}


}

/* End of file article.php */
/* Location: ./application/controllers/article.php */